﻿using DataAccess;
using KhoaLuan.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KhoaLuan.MainSys.Manager.Controls
{
    public partial class ctAddNewIntroduce : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                try
                {

                    var _introid = Request.QueryString["IntroID"];
                    var org = UserLogin.GetCurrentOrg;
                    if (org == null)
                        throw new Exception();
                    lbOrg.InnerHtml = org.NameOrg;

                    if (_introid != null)
                    {
                        var proxyintro = new tbIntroduce_Proxy();
                        var intro = proxyintro.GetById_tbIntroduce_Proxy(int.Parse(_introid)).ToObject<tbIntroduce>();
                        if (intro.OrgID != org.OrgID)
                        {
                            //mo 1 bai viet khong thuoc org da dang nhap
                            throw new Exception();
                        }
                        btnDangBai.Value = "Lưu";
                        if (intro != null)
                        {
                            txtTieuDe.Value = intro.Title;
                            txtNoiDung.Text = HttpUtility.HtmlDecode(intro.ContenIntroduce);
                            ckbCheckAll.Checked = intro.IsIntro;
                        }
                        else
                        {
                            //khong ton tai bai viet
                            throw new Exception();
                        }
                    }
                    else
                    {
                    }
                }
                catch (Exception)
                {
                    Response.Redirect("~/404.html");
                }
            }
        }
    }
}